import { GetUserRegister } from '@/api/user.js'

export default {
	data() {
		return {
			
		}
	},
	methods: {
		// 判断是否登录
		globalOnlogin() {
			return new Promise((resolve, reject) => {
				const token = uni.getStorageSync('token')
				
				if (token) return resolve(true)
				
				uni.showModal({
					title: '提示',
					content: '当前用户未登录,请前往登录！',
					success: res => {
						if (res.confirm) {
							uni.navigateTo({
								url: '/pages/Login/index',
								success: () => reject(false)
							})
						} else {
							reject(false)
						}
					},
					fail: () => reject(false)
				})
			})
		},
		
		// 查询用户是否为注册方
		globalOnRegister(ruleForm) {
			return new Promise((resolve, reject) => {
				Promise.try(async () => {
					return GetUserRegister(ruleForm)
				}).then(res => {
					resolve(true)
				}).catch(err => {
					reject(false)
				})
			})
		}
	},
	onLoad() {
		
	}
}